<template>
  <div class="swiper-container" ref="swiperContainer" :style="{width: panelWight -20 +'px',height:wrapperHeight+'px'}">
    <div class="swiper-wrapper">
      <div class="swiper-slide" v-for="(item,index) in bannerList" :key="index">
        <div class="img" >
          <router-link target="_blank" :to="{path:'/news/details',query:{bannerId:item.id}}">
            <img :src="item.path" alt="">
          </router-link>
        </div>
        <div class="bannerTitle">{{item.bannerTitle}}</div>
      </div>
    </div>
    <div class="swiper-button-prev" />
    <div class="swiper-button-next" />
  </div>
</template>

<script>
import Swiper from 'swiper'
export default {
  name: 'index',
  props:{
    bannerList: {
      type: Array,
      default: function () {
        return []
      }
    },
    model: {
      type: Boolean,
      default: false
    },
    wrapperHeight: Number,
    panelWight: Number,
  },
  data() {
    return {
      baseUrl: process.env.VUE_APP_BASE_API,
    }
  },
  created() {
    console.log(this.bannerList,"bannerList")
  },
  mounted() {

  },
  methods:{
    initSwiper(){

      this.swiper = new Swiper(this.$refs.swiperContainer, {
        autoplay: {
          delay: 3000,
          disableOnInteraction: false,
        },
        observer: true,
        loopAdditionalSlides:3,
        loop:true,
        observeParents: true,//修改swiper的父元素时，自动初始化swiper
        pagination: {
          el: '.swiper-pagination',
          dynamicBullets: true,
        },
        navigation: {
          nextEl: '.swiper-button-next',
          prevEl: '.swiper-button-prev',
        },
      })
    },
  }

}
</script>
<style>
.el-carousel__container{
  height:  100%!important;
}
</style>
<style scoped lang="scss">
.swiper-container{
  img{
    width: 100%;
    height: 100%;
  }
  .img1{
    height: 100%;
  }
}
.bannerTitle{
  text-align: center;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 25px;
  color: #fff;
}
</style>
